const lngLat2ThetaPhiXYZ = require('./lngLat2ThetaPhiXYZ').lngLat2ThetaPhiXYZ;
const glMatrix = require('gl-matrix');
const vec3 = glMatrix.vec3;
const mat3 = glMatrix.mat3;

// 由中心点的经纬度得出一个矩形的四角顶点信息
module.exports = function getTexturePolygon(lnglat, radius) {
    const spaceCoor = lngLat2ThetaPhiXYZ(lnglat, radius);

    const position = [];
    position.push(spaceCoor.x, spaceCoor.y, spaceCoor.z);
    position.push(spaceCoor.x, spaceCoor.y, spaceCoor.z);
    position.push(spaceCoor.x, spaceCoor.y, spaceCoor.z);
    position.push(spaceCoor.x, spaceCoor.y, spaceCoor.z);

    const side = [-1, 1, -1, -1, 1, -1, 1, 1];
    const uv = [0, 0, 0, 1, 1, 1, 1, 0];
    const index = [0, 1, 2, 0, 2, 3];

    return {
        spaceCoor: [spaceCoor.x, spaceCoor.y, spaceCoor.z],
        position: position,
        side: side,
        uv: uv,
        index: index
    }
}